'use strict'

import { dbConfig } from "../typings/user";
import { Sequelize } from 'sequelize-typescript';
import User from './user/user.model'
import * as mysql2 from 'mysql2';


export default class InitMysql {
    public sequelize: Sequelize;

    constructor(config: dbConfig, models?: string[]) {

        const conf: any = {
            ...config,
            dialect: "mysql",
            timezone: "+08:00",
            logging: false,
            dialectModule: mysql2,
            query: { raw: true },
            models: models || [User]
        };
        console.log(conf);
        this.sequelize = new Sequelize(conf);
    }
}
